package org.jimmy.tang.concurrent.atomic;

/**
 * @author jimmy
 * 
 */
public class CompareAndSwap {
    private volatile int value;

    public final int get() {
        return value;
    }

    public final int incrementAndGet() {
        for (;;) {
            int current = get();
            int next = current + 1;
            if (compareAndSet(current, next)) {
                return next;
            }
        }
    }

    public final boolean compareAndSet(int expect, int update) {
        // return unsafe.compareAndSwapInt(this, valueOffset, expect, update);
        return false;
    }

}
